Fix a bunch of warnings and errors