Cleaned up code

More organized and commented