Fixes #2622 on trunk; thanks ywu and steven. Unfortunately I don't know how to move these changes to the live site