Add all comments that needed. Rewrite code according to code
conventions.