Fix site id generation

The add method makes an assumption that the site id should be the total number of sites + 1. This assumption is not valid when any site excluding the last one is removed. The code attached changes the strategy for generating site id's to find the highest existing site id and +1 to that.