Clean up a lot of warnings and improve compile flags a bit