Fixed bugs and improved example