HSV refactored into .c source file