remove dead codes and unused codes, add generated serial IDs, update comments