several silly bugs fixed :) both in the library and in the demo