prevent IDs from being empty

+ better mangling for IDs