remove unused code

went through the scrutinizer report and fixed some obvious stuff like unused variables.