Add examples and fix some bugs.