Changed ordering of context generation - hopefully this fixes the ordering issue.