Fix memory error and detect new exceptions