Code clean up

And documentation