Manually merge of @PEM--'s changes