Cleanup and better newline + escape handling