Various fixes.

Pull request by request of Henry Soule.