Code Cleanup

Cleaned up code, after the last few days of experimentation it was
getting too messy