Refactoring, part 2

Signed-off-by: Piotr Bocheński <bochenski.piotr@gmail.com>