add with_roles helper & return distinct resources without select condition

also fixes some trailing whitespaces and unused variables