Adds support for empty lines and some refactor