Merge Heartbeat fix from http://stackoverflow.com/a/25495583/1570248