Change module state machine to be a real function using var-args, much more robust and clean solution.
Update output modules to new SM function.
Start implementing file output.