Use isEmpty instead of comparing size/length, close #343