Fixed some residual errors from the merge of issue47 into this branch, which is a fork of issue54.