Refactor friendship functionality.