Migrating all math.lua to PHP functions. Normalizing achievement.lua to main.lua.