Fix some bugs and add examples