adding proper doc comments to code. Cleaning etc.