add support for objects and some cleanup