updated code to wrap in closures
improvements to the build system