adding some missing imports; introducing some array comprehensions