Could you factor this and other constant objects (like modeInit and modeCompleted's options)out of this function? It makes for readability. I think it goes against Lisp style? But this is Javascript :)