gtsp.c refactor/clean-up