More bugs fixes found while debugging