Trying to figure out how to fix crashes is solver stuff
Added some safety checks to try and prevent solver from crashing