Fixes for porting to "stable" branch