Nifty Midcap & Smallcap Hit Fresh Records; Sensex Gains 0.87%