Class based lookups for the ORM

This PR implements class based lookups for the ORM.