Fix warnings, some formatting, and specify generics