Implementation of #128 on mainline