Fixing a concurrency bug in classification loop