Some additional commenting

Also some beautification of the overall code since it seems to not come
correctly indendit in github.