Ported some functions to C (pygsw)