Fixed buggy length calculation and a saner transition model

Etc.