EXTENSION-ified, added some code for rule-based marshalling (yech!)