Refactored code to make significantly cleaner. Fixed up output to make explicit which event is read and which is dumped. This resolves #27 for the moment.