Applying commit 1f91cdbefc2d45fb5510a3a47d926725f288eb87
Plus one bug fix!
Applied changes up to 8fa487a41c0e6816c7f6e76eed68db4e8d02ba70
Updating to commit 15eb
Basically adds to safety measures against null pointers.
Implemented 5737
Main structures are hashes, but still there are a couple of TODOs
Merge branch 'master' into last_working