Fixes per Nikita's suggestion