Whitespace changes before moving code.

Otherwise my editor is likely to cause extra changes we don't care
about.
Extract the usercode functions to their own file

Make use of decorators to provide a registration mechanism we can
extend to allow for which usercodes to use to be chosen at runtime.
Tidy imports so it's clear what comes from where

In particular, this exposes that the 'rate' function comes from
the external 'visual' module, rather than from one of the local
files.
Switch to using 'threading' rather than 'thread'

This is a higher level and somewhat nicer threading module and
(I believe) allows for easier control over the threads. Also collect
the threads into a list so we can do things with them later.