Fixed some race conditions
Removed some obsolete code
started adding counters