Minor changes - and fixed dup code

Removed duplicating code. Fixed comments and more minor things.