Added safetimeout function (High mem use, but safe.)