Added option for maxlen to be infinite