6.1 validIndex done, and clean up in other files