Clean up rebase, bring fix for #1874 into browserify branch