Comments on your code

I would mostly yes. The biggest issue i felt about the code is that even though you separated the concerns well into functions, you did separate the concerns very well in terms of closures (nested functions). This give a very convoluted aspect to the readability of the code. Most of it can be easily solved by separating your code in more files.