added main error loop, decreased heartbeat interval from 2s to 0.5s