Refactor auto-id generating mechanism and add # wildcard