Fix id generator, move main