We develop a unified framework for analyzing and optimizing costs for systems of FCFS queues with batch arrivals, setup delays and a general nonlinear cost structure that includes costs associated with energy used, setup times and Quality of Service (QoS) measures. We focus on the MX/G/1 and GeoX/G/1 queues with i.i.d. service times, but our results hold also for arbitrary i.i.d. batch structures where service times within a batch may depend on the batch size and have different, possibly dependent, distributions. We use the notion of value functions from the theory of Markov decision processes (MDPs), along with exponential cost functions, to develop the notion of, and simple expressions for, value generating functions. These can be used to find efficient energy control and job dispatching policies.