Added ability to switch direction in midair, cleaned up code