Added synchronized blocks around all iteration to avoid ConcurrentModificationExceptions closes #1494