merged changes in likelihood_functions (James)