Refactored parse code and added trig functions.