Cleaned up and commented history code