use lassign instead of foreach magic
added "unsafe" sections, badly needed for making lambdas safe to use with user supplied content.