Added the demonstration. Changed some internal functions