Fixed #640; progress on #638