General cleanup and minor bug fixes

Some restructuring of code
Minor fixes
Clean up of console and chat output