length does not seem to work with object arrays. Using max(size()) instead.