Changed from exceptions to return values
Added error handling for codes
Fixed return values and fixed error handling by the client