Added documentation

When reading through the source-code, I made some notes that resulted in this documentation here. I think that this might help also other programmers to understand the code more easily.