Cleanup and math fixing.