Working on #738 Database optimization
sid in templates must be signed, not unsigned