Add typespecs
Turn process_* functions private