Code appearance

Spaces to tabs, small fixes, add comments, cleanup