Cleaned up pendulum code