drop support for global functions and closures, fix examples, refactor mw code