move some stuff to engine.js in preparatin of metronome packaging