Reset history pos on submit and fixed addHistory to add at at start of array instead of end.