Further code prettification.
using map for brevity.
catching a specific exception rather than all of them.
Merge pull request #2 from catchagain/master

Cosmetic fixes.