fix 2 memory errors (only one of them introduced in this branch)