Changes from James Wachmann related to closure functions and variables