Added demo and fixed some bugs