Added object definitions, and upgraded code to use generic object functions