peeled out categories and cg functions to separate files, improved linto and movetos