jshint
DEBUG

Added lots of log calls and a couple small 'fixes' (attempts)