made standard gnu99 to avoid warnings, fixed few issues
casted to llu to avoid warnings