Rangers exorcised some of their Old Firm ghosts as they claimed a much-needed 2-1 win over Hearts at Ibrox.