Fix id generation, add tests, make the logs a bit saner