Implement session clearing for editing

Clear previous session when encountering editing errors to make sure latest version is loaded in form. With iths commit, a bug preventing this same session from beign set has been fixed.