Cleaned up attribute checking code to reduce nesting, added error mixing to simplify logging and quitting