Some output fixes, added checks before printing.