Some bug fix in main activity