Spaces instead of tabs; more consistency in formatting

It’s really hard to read this code on GitHub with tabs, so I reformatted it with spaces. I also made the visual formatting more consistent across the codebase.