move ObjectTemplate functions to handle classes

Use Mixin to add required methods to instantiated objects. Allows for
wrapper classes to manage their own features.
fix handling of handle.close()
bi-directional tcp communication