Made various changes to fix build issues on some systems