Fixed all the compile issues with the code commited by stephen, need to fix some more warnings