Reduce compiler warnings

Add generic specifications. Remove unused imports. Etc.