a lot of compiler warning fixes

I've fixed all compiler warnings and one bug.
don't write it if you don't use it