Fixing possible structure ID conflict

The current implementation had a possibility of structure IDs clashing
when the same structure ID was maintained across multiple namespace,
Fixed.

Added some comments also