Various fixes and improvements to exception handling, content providers, and directives