Fix/windows hardening

These series of changes are aimed at stopping tincan from crashing on both Windows and Linux mainly by cleaning up memory less aggressively (sometimes dubbed memory leak). Code is currently being tested on Windows, FutureGrid and so far no blow-ups. Hopefully it holds (fingers crossed).