Cleaned up code and tested.