Refactors and fixes newlines