generic factory for external scripts

- generic factory return object for external scripts required
- module functions to prototype
- getStack() common function