more documentation and code cleaning