Refactor of commit f17ce5ab07b9d514b58342eebf1899e13b1b5d60