Some optimizations for the favorite system