Add doc

Add doc
Add comments
realign code