move top-of-file clutter into a helpers include
[not fully tested] humongous overhaul to split apart mess that was index.js