refactored sync_get_state() to use counters like async_get_state().  It is sleightly slower but safer with memory and more readable.