Code refactoring

And even more.
Code refactoring

And final refactor, battery is almost empty and i'm leaving the train
anyways.