Added an explicit check for duplicate bars.