Improving an ugly ifstatement reported by Pavel Sokolov.

Also a minor format fix.