Avoid direct querying where possible, replace with calls to Versioned::g...

Replaced a couple of DB:query() calls with calls to Versioned::get_by_stage()