Partial implementation of #462