Minor tidying - lose a few globals, a few 'todos'