Thanks a lot. The bug at the beginning comes from the fact that I messed up with the tileset and put a tile without collisions at that place so the player fall below the level. I think it is the only place where it happens.