Finished up - made the math functions work, added comments