Minor database optimizations