fix critical mistake in data encoding algorithm, other minor fixes and improvements, add more samples