Fixed compile errors and warnings #687