Fixed some maths, refactored to standard python naming convention.