More versatile sate parsing + misc improvements