code cleanup

code has been organized, commented, and cleaned up.
certain actions handle in a way that is more organized or understandable, but still do the same thing.