Rewrite physics engine