rewrite2 some fixes so deploy plays nicely with heroku