Fixed compile errors and warnings under linux