Various fixes that didn't immediately cause crashes. Fixed long-standing issue with importFile that no one would ever notice.