Cleaned up some code, runs better and formats nicer.