Cleaning code and improving doc a little bit