a lot of compiler warning fixes

I've fixed all compiler warnings and one bug.
refferance to temporary object 0_O