Parameterized generic types

Change-Id: I0d7e19c187f5f45be94d09232ae678809e9cddf8
Typed the Comparator

Change-Id: I010ca701c13010fc50d91d8a5584b44929321f3b
Added more closing of IO resources

Change-Id: I68cd72f7a2c761c969cc707f0492b0f0f87c9591