node_count should probably not be casted to uint16_t now, otherwise this doesn't support more than 64K nodes