Manual rebase of #124 and #125