I find all this code so hard to read, because there are very few elements being <i>composed</i> together. It reads like one monolithic chunk of code (and with a global state!).<p>I find code enjoyable to read and write when it's like Lego. You build small little self contained pieces and join them together. It makes a big difference when building large applications.<p>I wrote an example in [Concur](<a href="https://github.com/ajnsit/concur" rel="nofollow">https://github.com/ajnsit/concur</a>) to demonstrate what I mean - <a href="https://gist.github.com/ajnsit/f0fee9a83480289a5a052273ce21cc1b" rel="nofollow">https://gist.github.com/ajnsit/f0fee9a83480289a5a052273ce21c...</a>. The "app" is composed of self-contained widgets, each of which are short and easy to read, and have a defined purpose (show the searchbox, render a story etc.) In a larger app, they can be mixed and matched together in logical ways.