Refactor retrieving valid users from ids
Make sending messages thread-safe