Tentative fix for #917, #737 - towards a cleaner build system