Fix some memory error handling in CT