Added correct id generation and time setting