Fixed several output bugs