Fixed exception and oriantation change bug.