Fix for BZ-1066469 plus some dependency file cleanup and reordering.