Cleaned up a bit of the code