Added Math functions & some code fixes.