Remove an used class
Make reference targets a non-undo property and clean up reference design

This resulted in a lot of const modifier propagation.
Fix a memory leak.
Fix a double delete bug and a related memory leak