We investigate the sub-leading contributions to the free energy of Bethe Ansatz solvable (continuum) models with different boundary conditions. We show that the Thermodynamic Bethe Ansatz approach is capable of providing the $ \mathcal{O}(1) \mathcal{O}(1) $ contributions are directly related to the exact g-function. In this paper we provide an all-orders proof of the previous results of P. Dorey et al. on the g-function in both massive and massless models. In addition, we derive a new result for the g-function which applies to massless theories with arbitrary diagonal scattering in the bulk.