Bug fixes to option generation code