finalized everything, now its just matter of tests and optimization
corrected previous commit
resolved conflict