make things so much neater: escaped newlines, better index checking