Moving code around to prevent unnecessary duplication. Using closure instead of options object to store data.