Orbit checking + more math optimizations