Fix warnings and a couple of errors