Merged with Kevin's source

Cleaned up output code