Fixed some bugs. Math is still a bit glitchy.