Fix bug in legend item placement