Fixes for bugs in the last commit