Recent research has investigated refined bounds for transmission over memoryless channels. This paper derives the following general expression for the volume of optimal length-$n$ codes for memoryless channels with average error probability $0 < epsilon < 1/2$: $M(n,epsilon) = exp{nC - sqrt{nV} ,Q^{-1}(epsilon) + frac{1}{2} log n + A_n + o(1)}$ where $C$ is the Shannon capacity, $V$ the channel dispersion, or second-order coding rate, and $A_n$ is a bounded sequence that can be explicitly identified. The derivation is based on strong large deviations analysis and is rooted in Laplace's method. The family of codes that achieve the optimal log-volume --- up to a few nats --- is characterized. While not optimal, Shannon's random codes are third-order optimal.