Changes to not drop the after context lines because of timeout
Some refactoring / Scalafication