Refactor command serialization.
Merge pull request #4 from m1ch1/master

Refactor command serialization.