fixed warnings and errors to pedantic c99 standard