Object handling

Moved from macros to functions