Cleaned up history changes code. Still borked