Be defensive against bad input.
Match brace style.
Merge pull request #2 from mbaltaks/master

Defend against bad input