Fixed several compiler warnings/sanity checks