Fix NPE crash and a poorly handled custom Exception.

This was @rock3r's fault.