Set C99 standard, fix various warnings and errors