Some fixes on orientation change

Commit 1 fixes #1673
Commit 2 fixes  #1655