Some refactoring.

Signed-off-by: Andras Mitzki <mitzkia@gmail.com>