Fix a lot of warnings/problems