Build improvements - less repetition

Please review and merge.