documentation & cleaning

added some more documentation and cleaned some code