Fixed compile errors and warnings