refactored a few things
Defined some math helper methods. These are not implemented yet.