fixes #3017 (less queries in toolbar middleware)

fixes #3017