Fix bug and some warning