Added demo and fixed a couple of bugs