Feature/trim connection redux

Reimplementation of trimming, this approach is better because it does not depend on any timeouts and it does not seem to crash. It is also less code, I think I have conquered this thing (fingers crossed)