Adding some bug fixes