Solved bugs when changing orientation.