Fix current build

This PR fixes issues #846 and #852, affecting the current build process. This work will eventually be superseded by issue #843.