Some code refactorings, Close button works in output view