[task] some refactorings, cleanup, final version