Efficient Query Rewriting in the Description Logic EL and Beyond