Fixed the example and some bugs