Fixed a bunch of build errors and a couple of warnings