bugfixed history mechanism

eraseState was pushing an invalid empty state
and viewPanel constructor was trying to switch to historic state
index, even if no view with that index actually exists.