Refactor code, split out maths to firemath.py

Instead of doing all of the math in firemarshal, use a module to keep
thing separate. This way it can be re-used in other systems if need be.