Cleanup of tarichasum.c, splitting out functionality, removing global variables