Update demo and various bugs fixed