docs and some code cleaning