Fixes issues with 96a05937b689e63bbd9da512de862d904b8a325b (#973, #310)