Insert Cycle alarm function and fix some bugs