bugfix & Code tidy

removed unused code.