Separate StablePtr and StableName tables (#7674)

To improve performance of StablePtr.
small tidyups and refactorings