Fix Linux build issues and bugs