Fixes drag drop bug. Some refactoring.