Optimized database

Trim the savedreply table when the row count reaches a certain limit.
Also optimize updatePins code and optimize the isSavedReply method.