Use visitors instead of ifs and gets.
Fix a problem with catching generic exceptions.