Remove non-free dependencies and fix build issues