Correcting some bugs