Refactored ErrorState to not be Singleton. Other minor cleanups as well.