some math and things
Fixed merge conflicts