Add Id and IdSpace validation and some debugging function