Code improvements based on code review feedback
Improved output layout somewhat + refactored some code