Added a parameter to limit the output size. This is an estimate, but should be good enough.