Added status code handling
Fixed handling of empty entity in error statuses