Refactored get and set code for ORM support