Clean up function declarations, loops, and whitespace.