Removed old Math-based approach + other tidying.