significant refactoring. Custom error codes and standard HTTP status codes.