handle server 5xx errors and improve readability and perf

Server errors should be processed like client errors, (aka reload page) and this PR fixes that.

This PR also contain small changes related to readability and performance, which I made during debuging this issue (with correct undo - redo browser buttons support)

marek