moved some code into hub.js, evening commit.

Hopefully this works.