fix context for custom importers and handlers
fix stack overflow and TypeError in resource managing