Fix up some code
Remove unused code