Silenced a bunch of warnings, fixed a bug

Simple changes. g++ 4.9.0 gave a lot of useful warnings that earlier versions did not, it even caught a bug, which has been fixed.