Refactored output generation Closes #52 Fixes #23