Namespace fixes and custom exceptions