Heavy flavours and QCD studies at HERA