copied these ideas from python-dbus bindings