Map loop distribution seems to work ok now.
Fixed code generator for replicate and subexps in general