Fixed errors and warnings from GCC/Clang