Consistent error responses, slight code cleanup