Remove unnecessary code and little code refactoring.

Signed-off-by: Janusz Kozerski <janusz.kozerski@gmail.com>