Moved Code into modules

moved most of the code into modules and adding a new math module for
future operations