Fix memory checking