Consistency tests for alignment, plus correction small but influential bug (replace startpos with cur_startpos in loop)