Output issue fix and cleanup