Critical bugs fixes