cleanup cg code
use const modifier where is possible
correct prototypes