Added some debug logs and hopefully fixed a crash instead of error for memory on mac