some fixes as suggested by ydubreuil