Improve script Context

Added support for nested contexts (and applied relevant changes where this feature is useful)
Reworked how free functions are handled
Cleaned dependencies between directories