Fixed problems in flatten() and islist()