I've made an attempt to fix some of the issues you've listed, although there's still much work to be done. I'll add some comments later.
Do you know when you'll have a chance to respond to reviews and provide a new patch?
Time is short and it's not encouraging that you say there is "still much work to be done". Perhaps it would be best to mark this "returned with feedback"?
Dmitry will provide a new version of patch today.
------ Alexander Korotkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company