Performance improvements in transition selection, other minor refactoring, comments