Add repr, fix some bugs
Rearrange/document.