made _elementContext public, extracted ElementContext class