fixed a bunch of warnings etc and a few errors