General code cleaned up. Modularized code in a more sensical manner.