Various build and source changes to fix issues with compilation