Fix a couple bugs; cleanup unused code/includes