Implemented countdownlatch. Lots of fixes and improvements.