refactor initialization to guarantee it's never called more than once
add compiling of nested functions