prevent flicker
fixed some bugs
fix minor bug