Refactored to work for XML bindings as well as interfaces.