Fix exceptions on sub-objects (reformat pull request from @Robinfr). Closes #2.