Take care of NaN or Inf in residuals or endogenous values

Also adds more debugging information. Closes #491
Merge pull request #492 from JohannesPfeifer/sim_debug_and_NaN

Take care of NaN or Inf in residuals or endogenous values