Add better documentation and clean a bit the code