Remove some unnecessary database queries