Cleaned up some code and fixed some unused warnings.