Minor variable refactoring
Raise ValueError on invalid encode/decode input