Add better support for overriding constants

As proposed in tracker item 3499 comment 1.