initial project import from KDevelop
Made this thing compile. Added null checks in the deallocation functions.