Many fixes.

including the debug/release flags when compiling c files.