Tweaks from ruby porting