Fix bug of conversion of float to int at the wrong moment. Add some debug info.