Added better exception handling around inner classes.  Thanks to Jonathan Caryl.