Hamilton hits four homers, ties MLB record