handle an IndexError on rearrange_* more gracefully and present message to user

(and remove some related unused functions)

fixes http://manage.dimagi.com/default.asp?87800