two bug fixes

as described in each commit