Fixed two compile warnings and possible bugs in the C code. Fixes #8