1.Changed implementation of count. (count with select max, returns the max scidx, but it could have been inserted to a bigger index not subsequent. Now count the actual number of rows in the table)