Fixed amsstore.sql (indexes, weird foreign key thing)