fix warnings; remove dead code; format code