Fix a bug, add more docs