Cup of joe

Made necessary changes and cleaned up the code in a few other areas.