Fix bugs in new script
Fix error messages when adding indexes
Bug fixes