Cleaned up code to make more legible.