Cleaned up various things

Mostly to make them easier to read, and removed some unneeded defines and variables.