Fix for 64bit time_t, also fix memory leak