fixing variable access in closure
trying to fix bugs with in memory factory
support multiple methods to be called on module close