Added a method for creating functions on the fly.
Added methods to handle access and calls to globals.
Fixed some dependency injection issues.