Partial merge of @covard's Pull request #70