Reorganize into multiple packages

Enable hrotti to be used like a library by removing global variables and moving
basically all of the code into a non-main package. The motivation for this is to
be able to use the broker in unit tests for other projects.