HV-439 Removing superfluous type-variables and some unchecked cast as well as other warnings