Fixed issues with Nan/Inf and log()