Improve interplay of getCode and state2string
Improve interplay of getCode and state2string

Fixes #598
Fixes #599
Also fix another implicit issue with variable-codelength data types

Anaphory/beast2,CompEvol/beast2,tgvaughan/beast2,tgvaughan/beast2,CompEvol/beast2,Anaphory/beast2,tgvaughan/beast2,CompEvol/beast2,CompEvol/beast2,tgvaughan/beast2,Anaphory/beast2,Anaphory/beast2