Refactor of \r & \n handling