Make main loop conform to planned api