cleaned up physics code a bit