Broke out maths hacks into their own function
Fixed typo in a comment