Refactor line splitting code in the daemon, and fix it so it works.