some code refactoring and mess cleaning

* still, not enough cleaning, though
* durations saved in variables
* some private methods extracted