again refactoring (+ I forgot to mention previous commit had first  non-trivial untested learning queue implementation)