Migrating SafeMap to a separate module and simplifying.