Refactors and fixes line breaker logic