fix life-cycle bugs