Use lexical binding, clean up unused code