Fix several build problems