Fixed content replacement for history api events and added some other nice things