fix some apf bugs and get it auto starting