HotFix, potentially fixes #260 through catching a null node

Added copyright
Reformatted code
Rearranged code

line 380 containing the hotfix for people who have a hard time finding it