Improved generic typing to remove unchecked warnings