Backported Heroku fixes to master branch
Merged in changes from master