order phases logically and backport drag-and-drop patch

https://bugzilla.mozilla.org/show_bug.cgi?id=609284