Bug fixes + output refactoring