A few potential bugs were removed in the process. Much code cleanup remains to be done.
This fixes most of the build warnings.