Fixes resource leaks and removes deprecated c_str() calls where possible
load timestamp properly