Use types, export more names, clean up