Minor fixes

This patch fixes some unrelated bugs missed out earlier