Various build system fixes