Fixed small mistakes in action history code. Added comments