Looks like it doesn't quite work without some refactoring to deal with a number of corner cases -- I'm going to modify what I have to use the API you suggested, though.