Made possible debug with old (pre 4.8) gdb (needed on Ubuntu)
- Now uses unique_ptr for returning pointers (fixed one of the crashes)
- Various small fixes