Add ClassRegistry and refactor ActiveRecordExt