Keeping ResultSet open as little as possible and fixing the count limit
This patch fixes the issues related to query updates and minimizes the potential of database locks.
It also fixes the model item count limit.