error handling, unique id finding improvements and others