Removed two synchronised block references from inner loops, as this seems to affect performance in some cases.