adding more isset checking

Also:
- //end coments on large code blocks
- addition of braces around some single line blocks