refactors, tests, stabilization