fixed several bugs and logs.