improvements, fixed bugs, tests