Make compatible with heroku.  Fix heartbeat bug.