Many improvements. Added samples, tests