Maintenance stuff

Some of the stuff on Alexander Sokolov commit 6c98307df792af0d91a5d109c35bcb7b8b34c500