Fix compiling errors and bugs after testing on Raspberry Pi.