add alternate substitution logic for Opal environment

- also qualify top-level constants