improved demo and fixed some bugs