Corey's superpowers unleashed

Huge overhaul on query optimization