Add doc and clean code