Optimizations and bug fixes

Made task scheduler faster, re-introduced undo/redo, fixed bugs in the
physics system, and also optimized the physics system to be faster.