Restructured in preperation for channels and go routines.