Inline docs and some cleaning on main script