Updated some queries to be more generic and require less amendment for new installations.