fixed includes for gamma_p, gamma_q
split out internal_math and added fwd mode inc_beta