Some refactoring, new output format