Refactor

I have removed unused code, have a look and let me if some more things needs to be deleted.