Charm, beauty and charmonium production at HERA-B