Fix query to get current number of submissions
Improve updates of submission tables