several bugfix

@daydayfree