Several fixes for the last commit