Fixed issue #8173: High memory usage when using alot of tokens, particularly with MSSQL