Fix some bugs for deploying on heroku