prefixed lS vars, moved anon functions to their own and many more small improvements