Correcting some remaining bugs