Merged anastas/wip changes r3156:3218 into trunk.