Improve state machine for suffix handling