Cleaned up code. Played with formatting. Still need to make this look nice.