Sorted the factor levels in the order required in the legend to avoid problems later. Reorganized ggplot calls.