Add some type checks for dbus messages, and remove some old code