Clean up/format code

Trying to make it more readable and consistent.