Fixed a bug with orientation changes