Added more logs and some bug fixes