Remove __proto__ hack from statemachine
Clean up some document-related inheritance issues