Extracting few methods to improve readability

Fixes gh-27