Build system cleanup and fixes