Refactoring to support return rich exceptions to the client on save  + reformatting for lib consistency.