added transition end helper and some more code cleanup