Implemented an history states mechanism

Need to be reviewed