add docs and minor refactoring
update docs, add deserialize function