Add more checks to prevent possible memory errors...