Improve handling of some pointers causing potential segfault This intends to close #924 #928 and #925