Adds onInit capability to run code when new Document() is run, improves functionality of toPlain() to work recursively.