Another few changes, played around with atomic counters, cleaned up codebase a little.