Clean up c++ code and add checks

Clean up the c++ code, such that it compiles without warnings and performs all the necessary checks, such that it can not cause segfaults.

Edited by Frank Sauerburger
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information