Code cleanup and timestamp correctness fix