Slight cody clean up. Locking and critical sections need to be implemented.