added docstrings. fixed typo in serialize