Fixed a ConcurrentModificationException with synchronized blocks