organized existing code into modules with imports into global scope.

Signed-off-by: Pepijn Kokke <pepijn.kokke@gmail.com>