Made some optimizations to some queries.
mend