Cleaned up a bit and improved code readability.