add and index commands

+ minor cleanings
test the 'index' command