Code format, tighten API, and use generics.