Clean up and organize drag-drop code