Clean up code style, add missing brackets and braces.