Fix example and remove minor bugs