Fixed some bugs, add minor features.