Replace tabs with spaces, fix lines with only opening braces, fix assorted bugs.