New way to generate id's and some fixes