more fixes & thoughts

(I marked my comments with "JR" so that you can jump to changes with
control F)
- fixed a few more potential crashes due to nullpointer substringing
- commented in a few thoughts and explanations