Cleanup

Cleaned up the code but there is still plenty to do...