Refactored this. The rest of the codebase has a couple of inline functions for `map()` as well, might make sense to refactor some of them as well.