Pu browse button fix

The main fix is in 811a614

There is some code clean-up which I did during the bug hunting. I fixed one more bug in formatter, which I approached during tests.