Fixed most of the warnings in a sensible way