Convert to module

Convert the singele-file extension to a module and split it up in
several files.
Needs a lot of cleanup, still.