Code refactor and error fixing

convert database timestamp to int64