Fix potential ordering issue, clean up some imports