Port and improve single file history part