Fixed a possible buffer overflow and added some documentation to some internals

This possible buffer overflow is actually more likely these days due to UUIDs.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>