Fix deallocation, move display to separate thread, cleanup code.