modify JS closures to make them correct :). Old ones are stupid